module Ch02(myDrop, myDrop2, myDrop3, lastButOne, lastButOne1) where

myDrop n xs = if n <= 0 || null xs
              then xs
              else myDrop (n - 1) (tail xs)

myDrop2 n xs | n <= 0 = xs
myDrop2 n [] = []
myDrop2 n (x:xs) = myDrop2 (n-1) xs

myDrop3 n [] = []
myDrop3 n xs | n <= 0 = xs
myDrop3 n (x:xs) = myDrop3 (n-1) xs

lastButOne xs = if null (tail (tail xs))
                then head xs
                else lastButOne (tail xs)

lastButOne1 (x:[y]) = x
lastButOne1 (x:xs) = lastButOne xs
